package com.google.code.swingonfire.showcase.utils;

import java.awt.Component;
import java.util.EventListener;

public class ConstantParameterDefinition<PARAMETER_TYPE> extends AbstractParameterDefinition<Component, PARAMETER_TYPE>
{

    private final PARAMETER_TYPE constant;

    @SuppressWarnings("unchecked")
    public ConstantParameterDefinition(String name, PARAMETER_TYPE constant)
    {
        super(name, (Class<? extends PARAMETER_TYPE>) ((constant != null) ? constant.getClass() : Void.TYPE));

        this.constant = constant;
    }

    @Override
    public Component createComponent(EventListener eventListener)
    {
        return null;
    }

    @Override
    public PARAMETER_TYPE getValue(Component component)
    {
        return constant;
    }

    @Override
    public void setValue(Component component, PARAMETER_TYPE value)
    {
        // intentionally left blank
    }

}
